<template>
	<view>
		<view class="flex w-full h-screen justify-center align-items-center">
			<uni-forms ref="form" :modelValue="form">
				<u-gap></u-gap>
				<uni-forms-item label="昵称" name="nickName">
					<uni-easyinput v-model="form.nickName" placeholder="请输入昵称" />
				</uni-forms-item>
				<uni-forms-item label="手机号" name="phonenumber">
					<uni-easyinput v-model="form.phonenumber" placeholder="请输入手机号" />
				</uni-forms-item>
				<uni-forms-item label="邮箱" name="email">
					<uni-easyinput type="email" v-model="form.email" placeholder="请输入邮箱"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item label="性别" required>
					<uni-data-checkbox v-model="form.sex" :localdata="sexs" />
				</uni-forms-item>
				<u-gap></u-gap>
				<u-gap></u-gap>
				<u-gap></u-gap>
				<u-gap></u-gap>
				<button type="default" @click="changeInfo(form)">确认</button>
			</uni-forms>
		</view>
	</view>
</template>

<script>
	import {
		mapState, //先导入mapState方法
		mapMutations,
		mapActions,
	} from "vuex";
	export default {
		data() {
			return {
				form: {
					"email": "",
					"nickName": "",
					"phonenumber": "",
					"sex": ""
				},
				// 单选数据源
				sexs: [{
					text: '男',
					value: '0'
				}, {
					text: '女',
					value: "1"
				}],
			};
		},
		methods: {
			...mapActions('user', ['changeInfo'])
		},
		computed: {
			...mapState('user', ['userInfo']),
		},
		onShow() {
			this.form = this.userInfo
		},
	}
</script>

<style>
	page {
		background-color: #dadada;
	}
</style>

<style lang="scss" scoped>

</style>